package com.msconfig.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/*
 * author: caojunhao
 * date  : 2020/5/14
 * desc  :重写ViewPager
 */
//禁止ViewPager滑动
public class ViewPagerSlideForbid extends ViewPager {

    //是否可以进行滑动
    private boolean isSlide = false;

    public ViewPagerSlideForbid(Context context) {
        super(context);
    }

    public ViewPagerSlideForbid(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void setSlide(boolean slide) {
        isSlide = slide;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return isSlide ? super.onInterceptTouchEvent(ev) : isSlide;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return isSlide ? super.onTouchEvent(ev) : isSlide;
    }

}
